﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using S.Produce.Read.Api.Application.Commands.WeaningCommands;

namespace S.Produce.Read.Api.Controllers
{
    /// <summary>
    /// 种母断奶控制器(读)
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class WeaningsController : ControllerBase
    {
        private readonly IMediator mediator;

        /// <summary>
        /// 构造方式注入
        /// </summary>
        /// <param name="mediator"></param>
        public WeaningsController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 获取种母断奶信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> WeaningSelect([FromQuery] WeaningSelectCommand command)
        {
            return Ok(await mediator.Send(command));
        }

        /// <summary>
        /// 反填种母断奶信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> WeaningBackfill([FromQuery]WeaningBackfillCommand command)
        {
            return Ok(await mediator.Send(command));
        }
    }
}
